package com.project_test.kun.travelling_1st.SplashPage;

import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.project_test.kun.travelling_1st.MainActivity;
import com.project_test.kun.travelling_1st.R;

public class SplashActivity extends AppCompatActivity {
    private Splash_Pager_Fragment splash;
    private Splash_One_page_Fragment onePage;
    private FragmentManager manager;
    private FragmentTransaction transaction;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        manager = getSupportFragmentManager();
        transaction = manager.beginTransaction();

        SharedPreferences sharedPreferences = getSharedPreferences("isOne",
                MODE_PRIVATE);
        boolean isOne = sharedPreferences.getBoolean("is", false);
        if (!isOne) {
            splash=new Splash_Pager_Fragment();
            transaction.add(R.id.splash_container, splash, "1");
            transaction.commit();
        } else {
            onePage=new Splash_One_page_Fragment();
            transaction.add(R.id.splash_container, onePage, "2");
            transaction.commit();
        }
    }

    public void btnJump(View view) {
        startActivity(new Intent(SplashActivity.this, MainActivity.class));
        finish();
    }
}
